@extends('layouts.layout')

@section('content')
    <style>
        .table td, .table th{ vertical-align:baseline; }
        @media screen and (max-width: 500px){
          .table{
            width: 300%;
            max-width: 300%;
          }
        }
    </style>
    <div class="row clearfix">
        <div class="col-lg-12 col-md-12 col-sm-12">
            <div class="card">
                <div class="header">
                    <h2>
                        <strong>管理员列表</strong>
                        <small>{{ $result->total() }}个用户</small>
                    </h2>
                    <ul class="header-dropdown">
                        <li class="dropdown"> <a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"></a>
                                <li>
                                        <a href="{{ route('admins.create') }}" class="btn btn-info btn-sm">
                                            <i class="glyphicon glyphicon-plus-sign"></i> 添加管理员
                                        </a>
                                </li>
                        </li>
                    </ul>
                </div>
                <div class="body table-responsive">
                    <table class="table">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>管理员</th>
                            <th>邮箱</th>
                            <th>角色名称</th>
                            <th>创建时间</th>
                            @can('edit_users', 'delete_users')
                                <th class="text-center">操作</th>
                            @endcan
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($result as $item)
                        <tr>
                            <td scope="row">{{ $item->id }}</td>
                            <td>{{ $item->name }}</td>
                            <td>{{ $item->email }}</td>
                            <td>{{ $item->roles->implode('name', ', ') }}</td>
                            <td>{{ $item->created_at->toDateTimeString() }}</td>
                            @can('edit_users')
                                <td class="text-center">
                                    @include('role.actions', [
                                        'entity' => 'admins',
                                        'id' => $item->id
                                    ])
                                </td>
                            @endcan
                        </tr>
                        @endforeach
                        </tbody>
                    </table>

                    {{ $result->links() }}
                </div>
            </div>
        </div>
    </div>
@endsection
